package com.youchuang.action.user;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.InterceptorRef;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;

import com.youchuang.action.BaseAction;
import com.youchuang.bean.User;
import com.youchuang.common.Constant;
import com.youchuang.service.UserService;

/**
 * 注册
 * 
 * @author Administrator
 *
 */
@Namespace(value = "/user")
@ParentPackage("shopping-default")
public class RegistAction extends BaseAction {
	private Logger logger = Logger.getLogger(RegistAction.class.getSimpleName());
	private User user;
	private String checkCode;

	@Resource
	private UserService userService;

	@Action(value = "regist", interceptorRefs = { @InterceptorRef(value = "tokenStack") }, results = {
			@Result(name = Constant.VERIFY, location = "/WEB-INF/jsp/user/verify_form.jsp") })
	public String execute() throws Exception {
		logger.info("RegistAction is execute");

		userService.registUser(user);
		return Constant.VERIFY;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getCheckCode() {
		return checkCode;
	}

	public void setCheckCode(String checkCode) {
		this.checkCode = checkCode;
	}

}
